﻿Imports System.Data.SqlClient

Partial Class _Default
    Inherits System.Web.UI.Page
    Dim cn As New SqlConnection(ConfigurationSettings.AppSettings("conn"))

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        If Session("username") = "Guest" Then
            Label10.Visible = False
        Else
            Label10.Visible = True
        End If



        If Session("username") <> "Guest" Then
            Try
                Dim cn As New SqlConnection(ConfigurationSettings.AppSettings("conn"))
                Dim cmd As New SqlCommand("select logindate from users where username='" + Session("username") + "'", cn)
                cn.Open()
                Dim str As String = cmd.ExecuteScalar
                Label10.Text = "Last successful login at : " + str
                cn.Close()
            Catch
            End Try
        End If



        If Session("username") = "admin" Then
            Label2.Text = Session("username")
            Try
                Dim cmd As SqlCommand = New SqlCommand("select count(imageid) from imagetable", cn)
                cn.Open()
                Label9.Text = cmd.ExecuteScalar
                cn.Close()

            Catch ex As Exception

            End Try
        Else
            Response.Redirect("login.aspx")
        End If
    End Sub

    Protected Sub LinkButton6_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles LinkButton6.Click
        Response.Redirect("Delete User.aspx")
    End Sub

    Protected Sub LinkButton7_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles LinkButton7.Click
        Response.Redirect("Delete picture.aspx")
    End Sub

    Protected Sub LinkButton8_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles LinkButton8.Click
        Response.Redirect("Delete Comment.aspx")
    End Sub

    Protected Sub LinkButton1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles LinkButton1.Click
        Response.Redirect("add_category.aspx")
    End Sub
End Class
